package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @Author whx
 * @Date 2024/12/14 21:58
 */
@RestController
@RequestMapping("/operation/activity")
@Api(tags = "优惠券活动管理接口")
@Slf4j
public class ActivityController {

    @Resource
    private IActivityService activityService;

    @GetMapping("/page")
    @ApiOperation("查询优惠券活动")
    public PageResult<ActivityInfoResDTO> pageQuery(ActivityQueryForPageReqDTO dto){
        return activityService.pageQuery(dto);
    }

    @PostMapping("/save")
    @ApiOperation("新增/保存优惠券活动")
    public void saveCoupon(@RequestBody ActivitySaveReqDTO dto){
        activityService.saveCoupon(dto);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询优惠券活动详情")
    public ActivityInfoResDTO getByCouponId(@PathVariable Long id){
        return activityService.getByCouponId(id);
    }

    @PostMapping("/revoke/{id}")
    @ApiOperation("撤销活动")
    public void revoke(@PathVariable Long id){
        activityService.revoke(id);
    }


}
